package com.zr.gdms.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.gdms.model.Student;
import com.zr.gdms.service.AdjustStudentCourseService;
import com.zr.gdms.service.CourseAdjustSrevice;
import com.zr.gdms.serviceimpl.AdjustStudentCourseServiceimpl;
import com.zr.gdms.serviceimpl.CourseAdjustSreviceimpl;

import net.sf.json.JSONObject;
//未选择课题学生分配未被选中的课题上
public class AdjustStudentCourseController extends HttpServlet{
	AdjustStudentCourseService sc=new AdjustStudentCourseServiceimpl();
	CourseAdjustSrevice cj=new 	CourseAdjustSreviceimpl();	
	@Override
			protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
				// TODO Auto-generated method stub
				doPost(req, resp);
			}
			@Override
			protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
			// TODO Auto-generated method stub
				resp.setCharacterEncoding("utf8");
				HttpSession session =req.getSession();
				int sid=Integer.parseInt(req.getParameter("sid"));			
				int cid=cj.SelectCourseCidSrevice(sid);
				String cstate=req.getParameter("cstate");
				String sstate=req.getParameter("sstate");
				PrintWriter pt=resp.getWriter();
				boolean  flag= sc.NoCourseStudent(sid, sstate);	
				if(flag){							 
					boolean flag1=cj.NoCourseAdjust(cid, cstate);
				if(flag1){						 
					  pt.write("1");
				}else{
					pt.write("0");
				}		
			}
			}
}
